namespace Xsxiaosa.Net
{
    using System;
    using System.Reflection;

    internal class Messages
    {
        // Methods
        static Messages()
        {
            Xsxiaosa.Net.Messages.InvalidAsyncCall = "Unable to asynchronously call non-existant method {0}.";
            Xsxiaosa.Net.Messages.InvalidEndCall = "The IAsyncResult object for the End{0} was not returned from the corresponding Begin{0} method on this class.";
            Xsxiaosa.Net.Messages.EndAlreadyCalled = "End{0} can only be called once for each asynchronous operation.";
            Xsxiaosa.Net.Messages.AsyncCallPending = "Another asynchronous operation is pending.";
            Xsxiaosa.Net.Messages.AsyncCallException = "Asynchronous call exception.";
            Xsxiaosa.Net.Messages.ArgumentIllegalPath = "Illegal characters in path.";
            Xsxiaosa.Net.Messages.ArgumentNullBuffer = "Buffer cannot be null.";
            Xsxiaosa.Net.Messages.ArgumentNullSocket = "Socket cannot be null.";
            Xsxiaosa.Net.Messages.ArgumentNullPath = "Path cannot be null.";
            Xsxiaosa.Net.Messages.ArgumentNullStream = "Stream cannot be null.";
            Xsxiaosa.Net.Messages.ArgumentNullHostname = "Hostname cannot be null.";
            Xsxiaosa.Net.Messages.ArgumentEmptyPath = "Path cannot be empty.";
            Xsxiaosa.Net.Messages.ArgumentEmptyString = "String cannot have zero length.";
            Xsxiaosa.Net.Messages.ArgumentEmptyHostname = "Hostname cannot be empty.";
            Xsxiaosa.Net.Messages.ArgumentZeroLengthCommand = "Command has zero length.";
            Xsxiaosa.Net.Messages.ArgumentInvalidOffset = "Invalid offset.";
            Xsxiaosa.Net.Messages.ArgumentUnsupportedCredential = "Unsupported credential type.";
        }

        public Messages()
        {
        }

        public static string GetString(string key)
        {
            return Xsxiaosa.Net.Messages.GetString(null, key);
        }

        public static string GetString(string key, params object[] values)
        {
            return Xsxiaosa.Net.Messages.GetString(null, key, values);
        }

        public static string GetString(Type type, string key)
        {
            FieldInfo info1;
            object obj1;
//jyj modify            string text1;
            try
            {
                if (type == null)
                {
                    type = typeof(Xsxiaosa.Net.Messages);
                }
                info1 = type.GetField(key);
                obj1 = info1.GetValue(null);
                if (obj1 == null)
                {
                    return key;
                }
                return obj1.ToString();
            }
            catch
            {
                return key;
            }
//jyj modify            return text1;
        }

        public static string GetString(Type type, string key, params object[] values)
        {
            string text1 = Xsxiaosa.Net.Messages.GetString(type, key);
            if (text1 == null)
            {
                return key;
            }
            return string.Format(text1, values);
        }


        // Fields
        public static readonly string ArgumentEmptyHostname;
        public static readonly string ArgumentEmptyPath;
        public static readonly string ArgumentEmptyString;
        public static readonly string ArgumentIllegalPath;
        public static readonly string ArgumentInvalidOffset;
        public static readonly string ArgumentNullBuffer;
        public static readonly string ArgumentNullHostname;
        public static readonly string ArgumentNullPath;
        public static readonly string ArgumentNullSocket;
        public static readonly string ArgumentNullStream;
        public static readonly string ArgumentUnsupportedCredential;
        public static readonly string ArgumentZeroLengthCommand;
        public static readonly string AsyncCallException;
        public static readonly string AsyncCallPending;
        public static readonly string EndAlreadyCalled;
        public static readonly string InvalidAsyncCall;
        public static readonly string InvalidEndCall;
    }}

